import numpy as np
import pandas as pd
from qtorch.strategy import Strategy

class DualMovingAverageStrategy(Strategy):
    """双均线策略（5日/20日）"""
    def __init__(self, fast_window=5, slow_window=20):
        self.fast_window = fast_window
        self.slow_window = slow_window
        
    def generate_signals(self, prices):
        ma_fast = prices.rolling(window=self.fast_window).mean()
        ma_slow = prices.rolling(window=self.slow_window).mean()
        signals = np.where(ma_fast > ma_slow, 1, -1)
        return signals.astype(int)